package com.ztesoft.huangfu.learning.springbbot.springboottheamleaf.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created with IntelliJ IDEA.
 * Author: huangfu.daohui
 * Date: 2018/6/9
 * Time: 14:28
 * Version: 1.0
 * Description:http://blog.battcn.com/2018/04/28/springboot/v2-web-thymeleaf/
 **/
@Controller
public class IndexController {
    private static final Logger _logger = LoggerFactory.getLogger(IndexController.class);

    /**
     * 主页
     * 返回页面
     * @param model
     * @return
     */
    @RequestMapping("/index")
    public ModelAndView index(Model model) {
        model.addAttribute("msg", "welcome huangfu!");
        return new ModelAndView("index");
    }
    // 返回string
    @GetMapping("/index2")
    @ResponseBody
    public String index2() {
        return "index";
    }

}